/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.informet.ipd.struts.action;

import com.informet.ipd.modelo.dao.OEstrategicoDao;
import com.informet.ipd.modelo.vo.OEstrategicoVO;
import com.informet.ipd.struts.form.OEstrategicoForm;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.apache.struts.actions.DispatchAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

/**
 *
 * @author LAPTOP01
 */
public class OEstrategicoAction extends DispatchAction {

    /* forward name="success" path="" */
    private final static String SUCCESS = "success";
    private Log log = LogFactory.getLog(this.getClass());

    /**
     * This is the Struts action method called on
     * http://.../actionPath?method=myAction1,
     * where "method" is the value specified in <action> element : 
     * ( <action parameter="method" .../> )
     */
    public ActionForward ingresarOEstrategico(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        OEstrategicoForm form1 = (OEstrategicoForm) form;
        int cod = 0;
        String desc = form1.getDescObj();
        int idObj=form1.getIdObj();

        OEstrategicoVO oEst = new OEstrategicoVO(cod,idObj, desc);
        new OEstrategicoDao().spMan(1, oEst);
     
        List listaObjetivo = new OEstrategicoDao().getlist();
        form1.setListaOEstrategico(listaObjetivo);
        return mapping.getInputForward();
    }

    public ActionForward editarOEstrategico(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
         OEstrategicoForm form1 = (OEstrategicoForm) form;
         int cod = form1.getCodObj();
         int idObj=form1.getIdObj();
         String desc = form1.getDescObj();
         OEstrategicoVO oEst = new OEstrategicoVO(cod,idObj ,desc);
         new OEstrategicoDao().spMan(2, oEst);
         List listaObjetivo= new OEstrategicoDao().getlist();
         form1.setListaOEstrategico(listaObjetivo);
        return mapping.findForward("editar");
    }

    public ActionForward eliminarOEstrategico(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        OEstrategicoForm form1 = (OEstrategicoForm) form;
        int cod = Integer.parseInt(request.getParameter("codObj"));
        OEstrategicoVO oEst = new OEstrategicoDao().selectById(cod);
        form1.setCodObj(oEst.getNUM_CODOBJ_PK());
        form1.setDescObj(oEst.getTX_DESCOBJ());
        new OEstrategicoDao().spMan(3, oEst);
        List listaObjetivo= new OEstrategicoDao().getlist();
        form1.setListaOEstrategico(listaObjetivo);
        return mapping.getInputForward();

    }
    
        public ActionForward  listarMObjetivo(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

            //listn call
            //request.setPaRAMETER(lista ,Lista)

        return mapping.findForward("prueba");
    }



    public ActionForward listarOEstrategico(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        OEstrategicoForm form1 = (OEstrategicoForm) form;
        List listaObjetivo = new OEstrategicoDao().getlist();
        form1.setListaOEstrategico(listaObjetivo);
        return mapping.getInputForward();
    }


}
